
var initAreaInfoBean;
var getAreaInfoBeanFromOpenPage = function(){
	var areainfoBean = {};
	areainfoBean.id = jQuery('#idEditor').val();
	
	
	areainfoBean.name = jQuery('#nameEditor').val();
	
	if(!areainfoBean.name){
		$.ligerDialog.error("请输入地名!");
		return null;
	}	areainfoBean.pid = jQuery('#pidEditor').val();
	
	if(!areainfoBean.pid){
		$.ligerDialog.error("请输入上级!");
		return null;
	}	areainfoBean.type = jQuery('#typeEditor').val();
	
	if(!areainfoBean.type){
		$.ligerDialog.error("请输入类型!");
		return null;
	}	
	return areainfoBean;
};

var initAreaInfoPage = function(){
	
	jQuery('#ligerType').ligerComboBox({
		data:areaTypeRenderData,
		valueField:'value',
		textField:'text',
		valueFieldID:'typeEditor'
	});
	
};

var bindAreaInfoUpdateButtom = function(){
	jQuery('#updateEdit').unbind('click').click(function(){
		var areainfoBean = getAreaInfoBeanFromOpenPage();
		if(null != areainfoBean){
			doSaveAreaInfos([areainfoBean]);
		}
	});
};
var bindAreaInfoResetButtom = function(){
	jQuery('#resetEdit').unbind('click').click(function(){
		if(!initAreaInfoBean){
			jQuery("#nameEditor").val('');
			jQuery("#pidEditor").val('');
			jQuery("#typeEditor").val('');
		}else{
			if(!initAreaInfoBean.name){
				jQuery("#nameEditor").val('');
			}else{
				jQuery("#nameEditor").val(initAreaInfoBean.name);
			}
			if(!initAreaInfoBean.pid){
				jQuery("#pidEditor").val('');
			}else{
				jQuery("#pidEditor").val(initAreaInfoBean.pid);
			}
			if(!initAreaInfoBean.type){
				jQuery("#typeEditor").val('');
			}else{
				jQuery("#typeEditor").val(initAreaInfoBean.type);
			}
		}
	});
};



jQuery(function(){
	initAreaInfoPage();
	bindAreaInfoUpdateButtom();
	bindAreaInfoResetButtom();
});